package cn.xy.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class TestController {

    //进入页面首页
    @RequestMapping("/gomain")
    public String goMain(){
        return "main";
    }

    //进入登录页面
    @RequestMapping("/gologin")
    public String goLogin(){
        return "login";
    }


    @RequestMapping("/login")
    public String test(String name, HttpSession session){
        session.setAttribute("name",name);
        System.out.println(name);
        return "main";
    }

    @RequestMapping("/logout")
    public String logout(HttpSession session){
        session.removeAttribute("name");
        return "redirect:/index.jsp";
    }


}
